package com.gperp.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gperp.mapper.AsLogsMapper;
import com.gperp.pojo.AsLogs;
import com.gperp.pojo.AsLogsExample;
import com.gperp.service.LogsService;

@Service
public class LogsServiceImpl implements LogsService{
	@Resource
	private AsLogsMapper asLogsMapper;
	
	@Override
	public Map<String, Object> queryList(Integer pageNo, String usercode) {
		Map<String,Object> map = new HashMap<String,Object>();
		PageHelper.startPage(pageNo, 8);
		AsLogsExample example = new AsLogsExample();
		example.createCriteria().andUsernameEqualTo(usercode);
		example.setOrderByClause("Operatedatetime desc");
		PageInfo<AsLogs> pageInfo = new PageInfo<AsLogs>(asLogsMapper.selectByExample(example));
		map.put("pageTotal", pageInfo.getTotal());
		map.put("pageList", pageInfo.getList());
		return map;
	}

	@Override
	public boolean savLog(AsLogs log) {
		return asLogsMapper.insert(log)>0;
	}

}
